package com.yuntsg.nnsfcp.util.httpclient;

import lombok.SneakyThrows;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringJoiner;

/**
 * @Author: 葛成瑞
 * @Date: 2021/7/18 20:27
 */

public class SmallTool {

    @SneakyThrows
    public static void SleepMillis(Long l) {
        Thread.sleep(l);

    }


    @SneakyThrows
    public static void SleepMillis(int l) {
        printMess("睡眠开始+++" + l);
        Thread.sleep(l);

    }

    public static void printMess(Object s) {
        String res = new StringJoiner("\t|\t")
                .add(longToDate1(System.currentTimeMillis()))
                .add(String.valueOf(Thread.currentThread().getId()))
                .add(Thread.currentThread().getName())
                .add(s.toString())
                .toString();
        System.out.println(res);

    }

    public static void printMessError(Object s) {
        String res = new StringJoiner("\t|\t")
                .add(longToDate1(System.currentTimeMillis()))
                .add(String.valueOf(Thread.currentThread().getId()))
                .add(Thread.currentThread().getName())
                .add(s.toString())
                .toString();
        System.err.println(res);

    }

    public static String longToDate1(long i) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date(i);
        String str = sdf.format(date);
        return str;
    }
}
